package com.seocoo.worker.order.widget;

import android.content.Context;
import android.support.constraint.ConstraintLayout;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.View;
import android.widget.TextView;

import com.seocoo.worker.R;

/***
 *订单详情顶部布局
 */
public class OrderDetailReceivingView extends ConstraintLayout {

    private TextView tvOrderState;
    private TextView tvPrice;
    private TextView tv1_1;
    private TextView tv1_2;

    public OrderDetailReceivingView(Context context) {
        super(context);
        initView(context);
    }

    public OrderDetailReceivingView(Context context, AttributeSet attrs) {
        super(context, attrs);
        initView(context);
    }

    public OrderDetailReceivingView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        initView(context);
    }

    private void initView(Context context) {
        View view = inflate(context, R.layout.order_detail_receiving_layout, this);
        tvOrderState = view.findViewById(R.id.tv_order_state);
        tvPrice = view.findViewById(R.id.tv_price);
        tv1_1 = view.findViewById(R.id.tv1_1);
        tv1_2 = view.findViewById(R.id.tv1_2);
    }

    public void initData(String price, String state) {

        tvOrderState.setText(state);
        if (!TextUtils.isEmpty(price)) {
            tvPrice.setText(String.format("￥%s", price));
            tv1_2.setVisibility(GONE);
            tv1_1.setVisibility(VISIBLE);
            tvPrice.setVisibility(VISIBLE);
        } else {
            tv1_2.setVisibility(VISIBLE);
            tv1_1.setVisibility(GONE);
            tvPrice.setVisibility(GONE);
        }

    }

    public TextView getTvPrice() {
        return tvPrice;
    }

    public void setTv1_1Text(String text) {
        tv1_1.setText(text);
    }

    public TextView getTvOrderState() {
        return tvOrderState;
    }
}
